package com.onejson.ojmall.controller;


import com.onejson.ojmall.common.domain.PageResult;
import com.onejson.ojmall.common.apiencrypt.domain.ValidateList;
import com.onejson.ojmall.common.domain.ResponseDTO;
import com.onejson.ojmall.model.form.SRoleUserBatchForm;
import com.onejson.ojmall.model.form.SRoleUserForm;
import com.onejson.ojmall.model.form.SRoleUserQueryForm;
import com.onejson.ojmall.model.vo.SRoleUserVO;
import com.onejson.ojmall.service.SRoleUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;


/**
 * 角色用户功能表控制器
 *
 * @author wxx
 */
@Slf4j
@RestController
@Tag(name = "角色用户功能表")
public class SRoleUserController {


    //【角色用户功能表】Service层

    @Resource
    private SRoleUserService sRoleUserService;


    @Operation(summary = "【角色用户功能表】 - 查询")
    @PostMapping("/zichan/sRoleUser/queryPage")
    public ResponseDTO<PageResult<SRoleUserVO>> querySRoleUser(@RequestBody @Valid SRoleUserQueryForm queryForm) {
        return ResponseDTO.ok(sRoleUserService.getList(queryForm));
    }

    @Operation(summary = " 【角色用户功能表】 - 详情")
    @GetMapping("/zichan/sRoleUser//{detailId}")
    public ResponseDTO<SRoleUserVO> getInfo(@PathVariable("detailId") String detailId) {
        return ResponseDTO.ok(sRoleUserService.queryById(detailId));
    }

    @Operation(summary = " 【角色用户功能表】 - 添加")
    @PostMapping("/zichan/sRoleUser/add")
    public ResponseDTO<String> addSRoleUser(@RequestBody @Valid SRoleUserForm addForm) {
        return sRoleUserService.addSRoleUser(addForm);
    }

    @Operation(summary = "【角色用户功能表】 - 更新")
    @PostMapping("/zichan/sRoleUser/update")
    public ResponseDTO<String> updateSRoleUser(@RequestBody @Valid SRoleUserForm updateForm) {
        return sRoleUserService.updateSRoleUser(updateForm);
    }

    @Operation(summary = "【角色用户功能表】 - 批量更新")
    @PostMapping("/zichan/sRoleUser/batchUpdate")
    public ResponseDTO<String> batchUpdateSRoleUser(@RequestBody @Valid SRoleUserBatchForm sRoleUserBatchForm) {
        return sRoleUserService.batchUpdateSRoleUser(sRoleUserBatchForm);
    }

    @Operation(summary = "【角色用户功能表】 - 批量删除")
    @PostMapping("/zichan/sRoleUser/batchDelete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<String> idList) {
        return sRoleUserService.batchDelete(idList);
    }

    @Operation(summary = "【角色用户功能表】 - 单个删除")
    @GetMapping("/zichan/SRoleUser/delete/{id}")
    public ResponseDTO<String> batchDelete(@PathVariable String id) {
        return sRoleUserService.delete(id);
    }

}

